<%@ page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false" pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
<head><script type="text/javascript" src="/utils/scripts/flat-ui.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"><link rel="shortcut icon" href="/utils/image/favicon.ico" type="image/x-icon" />
<meta charset="UTF-8">
<title>学生信息管理系统</title>
<script type="text/javascript" src="/utils/js/jquery-3.3.1.min.js"></script>
<!-- Loading Bootstrap -->
<link href="/utils/css/vendor/bootstrap.min.css" rel="stylesheet">
<!-- Loading Flat UI Pro -->
<link href="/utils/css/flat-ui.css" rel="stylesheet">
<!-- Loading Flat UI JS -->
<script type="text/javascript" src="/utils/scripts/flat-ui.min.js"></script>
<script type='text/javascript' src='/utils/scripts/particles.js'></script><link href="/utils/css/animate.css" rel="stylesheet"></head>

<body><div id="particles-js"><canvas class="particles-js-canvas-el" width="1322" height="774" style="width: 100%; height: 100%;"></canvas></div>
	<jsp:include page="adminLeft.jsp" />
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<h5>课程管理</h5>
				
				<form name="studentquery" action="/courseServlet.do?flag=page&pageIndex=1" method="post">
					<div class="row">
						<div class="col-md-4">
							<strong>查询条件<br></strong> <select name="type"
								class="form-control select select-primary select-block mbl">
								<option value="-1" ${requestScope.type==-1?'selected':''}>全部课程</option>
								<option value="1" ${requestScope.type==1?'selected':''}>按课程编号查询</option>
								<option value="2" ${requestScope.type==2?'selected':''}>按课程名查询</option>
								<option value="3" ${requestScope.type==3?'selected':''}>按所属学院查询</option>
								<option value="4" ${requestScope.type==4?'selected':''}>按课程类型查询</option>
							</select>
						</div>
						<div class="col-md-4">
							<strong>条件</strong>
							<div class="form-group has-feedback">
								<input type="text" name="condition" value="${requestScope.condition}" placeholder="输入搜索条件"
									class="form-control" />
							</div>
						</div>
						<div class="col-md-3 pos">
							<br> <input type="submit" class="btn btn-primary" value="查询" />
						</div>
					</div>
				</form>

			</div>
			<div class="col-md-12">
				<div class="row">
				<div class="col-md-12" >
						<div class="margin:0 15px" style="overflow-x: scroll;">
				<table class="table table-striped table-hover animated fadeIn">
					<thead id="classinformation">
						<tr>
							<th>课程号</th>
							<th>课程名</th>
							<th>课程简介</th>
							<th>类型</th>
							<th>所属学院</th>
							<th>所属专业</th>
							<th>修改</th>
							<th>删除</th>
						</tr>
					</thead>

						<c:forEach items="${requestScope.pageUtils.records}" var="item">
						<tr>
							<td>${item.cid}</td>
							<td>${item.cname}</td>
							<td>${item.cintroduction}</td>
							<td>${item.type}</td>
							<td>${item.belongcoll}</td>
							<td>${item.belongpro}</td>
							<td><a class="btn btn-default" href="/courseServlet.do?flag=toupdate&cid=${course.cid}">修改 </a></td>
							<td><a class="btn btn-default" class="deleteCss" href="javascript:deleteCourse(${course.cid});"> 删除 </a></td>
						</tr>
					</c:forEach>

				</table>
				</div></div></div>
			</div>
		</div>
		
		
			
	<!-- 显示分页信息 -->
	<div class="row">
		<!--分页文字信息  -->
		<div class="col-md-6">当前 ${requestScope.pageUtils.pageIndex+1}页,总${requestScope.pageUtils.pageCount}页,总 ${requestScope.pageUtils.countAll } 条记录</div>

		<!-- 分页条信息 -->
		<div class="col-md-6">
			<nav aria-label="Page navigation">
			<ul class="pagination bg-primary">

				<li><a href="/courseServlet.do?flag=page&pageIndex=1&type=${requestScope.type}&condition=${requestScope.condition}">首页</a></li>

				<c:if test="${requestScope.pageUtils.pageIndex>1}">
					<li><a href="/courseServlet.do?flag=page&pageIndex=${requestScope.pageUtils.pageIndex-1}&type=${requestScope.type}&condition=${requestScope.condition}"
						aria-label="Previous"> <span aria-hidden="true">上一页</span>
						</a>
					</li>
				</c:if>

				<c:forEach items="${requestScope.pageUtils.num}" var="page_Num">
					<c:if test="${requestScope.pageUtils.pageIndex==page_Num}">
						<li class="active"><a href="#">${page_Num}</a></li>
					</c:if>
					<c:if test="${requestScope.pageUtils.pageIndex!=page_Num}">
						<li><a href="/courseServlet.do?flag=page&pageIndex=${page_Num}&type=${requestScope.type}&condition=${requestScope.condition}">${page_Num}</a></li>
					</c:if>
				</c:forEach>

                <c:if test="${requestScope.pageUtils.pageIndex<requestScope.pageUtils.pageCount}">
					<li><a href="/courseServlet.do?flag=page&pageIndex=${requestScope.pageUtils.pageIndex+1}&type=${requestScope.type}&condition=${requestScope.condition}"
						   aria-label="Next"> <span aria-hidden="true">下一页</span>
					</a>
					</li>
				</c:if>


				<li><a href="/courseServlet.do?flag=page&pageIndex=${requestScope.pageUtils.pageCount}&type=${requestScope.type}&condition=${requestScope.condition}">末页</a></li>
			</ul>
			</nav>
		</div>
	</div>
		
		
	</div>
	<script>
		$("select").select2({
			dropdownCssClass : 'dropdown-inverse'
		});


		//删除课程
		function deleteCourse(cid) {
			if(confirm("确定要删除该课程嘛?")){
				location.href="/courseServlet.do?flag=delete&cid="+cid;
			}
		}

	</script>
<script type="text/javascript" src="/utils/scripts/flat-ui.js"></script>
<script src="/utils/scripts/bganimation.js"></script></body>
<script type="text/javascript">
	// $(function () {
	// 	$.ajax({
	// 		type:'post',
	// 		url:
	// 	})
	// })
</script>
</html>